package com.sanbi.erp.core.system;

import com.github.houbb.property.bs.PropertyBs;
import com.sanbi.erp.core.config.UserConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

public class Enums {
    private static final String userLevel1Name;
    private static final String userLevel2Name;
    private static final String userLevel3Name;
    private static final String userLevel4Name;
    private static final String userLevel5Name;
    private static final String userDiscount1;
    private static final String userDiscount2;
    private static final String userDiscount3;
    private static final String userDiscount4;
    private static final String userDiscount5;
    private static final Integer score1;
    private static final Integer score2;
    private static final Integer score3;
    private static final Integer score4;
    private static final Integer score5;

    // 分销二维码描述
    private static final String qrCode;

    private static final String userRuleDesc;

    static {
        UserConfig userConfig = new UserConfig();
        PropertyBs.getInstance("user.properties").asBean(userConfig);
        // 分销二维码描述
        qrCode = userConfig.getQrCode();

        // 会员描述
        userLevel1Name = userConfig.getStart1Name();
        userLevel2Name = userConfig.getStart2Name();
        userLevel3Name = userConfig.getStart3Name();
        userLevel4Name = userConfig.getStart4Name();
        userLevel5Name = userConfig.getStart5Name();

        // 折扣(零售)
        userDiscount1 = userConfig.getStar1Retail().toString();
        Integer two = 100 - userConfig.getStar2Retail();
        userDiscount2 = two.toString();
        Integer three = 100 - userConfig.getStar3Retail();
        userDiscount3 = three.toString();
        Integer four = 100 - userConfig.getStar4Retail();
        userDiscount4 = four.toString();
        Integer five = 100 - userConfig.getStar5Retail();
        userDiscount5 = five.toString();

        // 积分
        score1 = userConfig.getStar1Score();
        score2 = userConfig.getStar2Score();
        score3 = userConfig.getStar3Score();
        score4 = userConfig.getStar4Score();
        score5 = userConfig.getStar5Score();

        // 会员介绍
        userRuleDesc = userConfig.getUserRuleDesc();
    }

    /**
     * @author wanggang
     * @desc 文件类型
     * @time 2022/7/18 10:31
     */
    public enum FileType {
        Jpg(1, "image/jpg"),
        Png(2, "image/png"),
        Gif(3, "image/gif"),
        NotImage(415, "NotImage");

        private final int code;
        private final String type;

        FileType(int code, String type) {
            this.code = code;
            this.type = type;
        }

        public int getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public static FileType getItem(String type) {
            for (FileType item : FileType.values()) {
                if (item.getType() == type) {
                    return item;
                }
            }

            return FileType.NotImage;
        }
    }

    /**
     * @author wanggang
     * @desc 优选类别
     * @time 2022/8/2 15:22
     */
    public enum BestType {
        History(1, "历史优选"),
        Today(2, "今日优选"),
        ComingSoon(3, "即将开市");

        private final int code;
        private final String type;

        BestType(int code, String type) {
            this.code = code;
            this.type = type;
        }

        public int getCode() {
            return code;
        }

        public String getType() {
            return type;
        }
    }

    /**
     * @author wanggang
     * @desc 对象类别
     * @time 2022/7/15 16:47
     */
    public enum ObjectType {
        ProductSku(16, "货品sku", "3B"),
        ProcurementPlanSn(17, "采购计划Sn", "CGJ"),
        Goods(1, "商品", "G"),
        Product(2, "货品", "P"),
        ShoppingOrder(3, "购物订单", "SO"),
        PayOrder(4, "支付订单", "PO"),
        ExpressOrder(5, "物流订单", "EO"),
        RefundOrder(6, "退款订单", "RFO"),
        ReturnOrder(7, "退货订单", "RTO"),
        TransferOrder(8, "转账订单", "TO"),
        WithdrawOrder(9, "提现订单", "WO"),
        DistributeIncomeOrder(10, "分销收入订单", "DIO"),
        DistributeRefundOrder(11, "分销退款订单", "DRFO"),
        DistributeReturnOrder(12, "分销退货订单", "DRTO");

        private final int code;
        private final String type;
        private final String prefix;

        ObjectType(int code, String type, String prefix) {
            this.code = code;
            this.type = type;
            this.prefix = prefix;
        }

        public int getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public String getPrefix() {
            return prefix;
        }
    }

    /**
     * 分销名片描述
     */
    public enum ObjectQrCode {
        QrCode(qrCode);

        private final String desc;

        ObjectQrCode(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }

    }

    /**
     * 商品工具枚举
     */
    @AllArgsConstructor
    @ToString
    public enum GoodsHelp {
        brand("Marca");
        private final String name;

        public String getName() {
            return name;
        }

    }

    /**
     * @author wanggang
     * @desc 会员等级
     * @time 2022/7/15 16:47
     */
    public enum UserLevel {
        Star1(1, userLevel1Name, userDiscount1, score1),
        Star2(2, userLevel2Name, userDiscount2, score2),
        Star3(3, userLevel3Name, userDiscount3, score3),
        Star4(4, userLevel4Name, userDiscount4, score4),
        Star5(5, userLevel5Name, userDiscount5, score5);

        private final int level;
        private final String name;
        private final String discountDesc;
        private final Integer score;

        public Integer getScore() {
            return score;
        }

        static public UserConfig userConfig;

        UserLevel(int level, String name, String discountDesc, Integer score) {
            this.level = level;
            this.name = name;
            this.discountDesc = discountDesc;
            this.score = score;
        }

        public int getLevel() {
            return level;
        }

        public String getName() {
            return name;
        }

        public String getDiscountDesc() {
            return discountDesc;
        }

        /**
         * 根据用户的会员等级获取对应的枚举
         *
         * @param level 用户等级
         * @return
         */
        public static UserLevel getItem(int level) {
            for (UserLevel userLevel : UserLevel.values()) {
                if (userLevel.getLevel() == level) {
                    return userLevel;
                }
            }
            return UserLevel.Star1;
        }

    }

    /**
     * @desc 会员介绍
     */
    public enum UserRuleDescIntroduce {
        Introduce(userRuleDesc);

        private final String introduce;

        UserRuleDescIntroduce(String introduce) {
            this.introduce = introduce;
        }

        public String getIntroduce() {
            return introduce;
        }
    }

    /**
     * @Desc: 支付类型设置
     */
    @ToString
    @AllArgsConstructor
    public enum getPayOrderType {
        Ping_Pong_Pay((short) 1, "Pago por Pingpong"),
        Tao_Gold_Pay((short) 2, "Pago por moneda UNO"),
        Ping_Pong_And_Tao_Pay((short) 3, "Pago combinado");
        @Getter
        private final Short type;
        @Getter
        private final String typeName;
    }

    /**
     * @Desc: 运单类型设置
     */
    @ToString
    @AllArgsConstructor
    public enum getExpressOrderStatus {
        waitPicking((short) 1, "待拣货"),
        inTransit((short) 2, "运输中"),
        Completed((short) 3, "已完成"),
        OrdersFail((short) 4, "下单失败");
        @Getter
        private final Short type;
        @Getter
        private final String typeName;
    }

    /**
     * @Desc: 订单操作状态键值
     */
    @ToString
    @AllArgsConstructor
    public enum getOrderStatusKey {
        //        Cancel("cancel"),// 取消操作
        Delete("delete"),// 删除操作
        Pay("pay"),// 支付操作
        UnPay("cancelPay"),// 取消支付操作
        Comment("comment"),// 评论操作
        Confirm("confirm"),// 确认收货操作
        Refund("refund"),// 申请退款操作
        Returns("returns"),//申请退货
        CancelReturns("cancelReturns"),//取消退货
        ReturnsInfoUpload("returnsInfoUpload"),//退货信息上传（修改退货信息）
        CancelRefund("cancelRefund"),//取消退款
        ReturnsHandle("returnsHandle"),//修改退货信息
        Service("service"),//联系客服标识
        Rebuy("rebuy"),// 再次购买标识
        //        Aftersale("aftersale"),// 售后操作
        Logistics("logistics"),// 查看物流
        UnComment("unComment"),//已评价标识
        ShoppingCart("shoppingCart");// 加入购物车操作
        @Getter
        private final String status;
    }

    public static void main(String[] args) {
        UserLevel userLevel = UserLevel.getItem(0);
        System.out.println(userLevel.getLevel());
    }
}
